import React from "react";
import { Tabs } from "antd-mobile";
import TabView from "./TabView";
import "../../styles/Attention/tabs.scss";
import myaxios from "../../axios/axiosattention";




export default class Demo extends React.Component {
  renderContent = (tab) => (
    <div className="wrap" style={{ height: "569px", backgroundColor: "#fff" }}>
      <TabView index={tab.sub} data={this.state.getData} ></TabView>
    </div>
  );

  state = {
    getData: [],
  };
  /* 请求数据 */
  componentDidMount() {
    myaxios.get("276089/recommend/list").then((res) => {
      let result = res.txt_list;
      console.log(result);
      this.setState({
        getData: result,
      });
    });
  }

  render() {
    const tabs = [
      { title: "综合", sub: 1 },
      { title: "二手房", sub: 2 },
      { title: "租房", sub: 3 },
      { title: "新房", sub: 4 },
      { title: "商业地产", sub: 5 },
      { title: "装修", sub: 6 },
      { title: "海外地产", sub: 7 },
    ];

    return (
      <div>
        <Tabs
          tabs={tabs}
          renderTabBar={(props) => <Tabs.DefaultTabBar {...props} page={6} />}
        >
          {this.renderContent}
        </Tabs>
      </div>
    );
  }
}
